package com.haiya.lsp;

public class LiskovSubstitution2 {
}

class Base {

}

class A1 extends Base {
    public int func1(int a, int b){
        return a-b;
    }
}

class B1 extends Base {
    private A1 a = new A1();
    public int func1(int a, int b) {
        return a + b;
    }

    public int func2(int a, int b) {
        return func1(a, b) + 100;
    }

    /**
     * 这里我们希望用到A1的方法，那么我们只要使用依赖、聚合、组合的方式来实现
     * @param a
     * @param b
     * @return
     */
    public int func3(int a, int b) {
        return this.a.func1(a, b);
    }
}